import { tryOnScopeDispose } from '@vueuse/shared'
import { WatchStopHandle } from 'vue'
export const useWatch = (source:any, callback:any, options = {} as any) => {
	let watcher:WatchStopHandle | null = watch(source, callback, options)
	tryOnScopeDispose(()=>{
		watcher && watcher()
		watcher = null
	})
	return watcher
}
export const useWatchEffect = (callback:any,options = {} as any) => {
	let watcher:WatchStopHandle | null = watchEffect(callback,options)
	tryOnScopeDispose(()=>{
		watcher && watcher()
		watcher = null
	})
    return watcher
}